<template>
  <div class="content_header">
    <!-- <div class="content_header_logo"></div>
 -->
    <div class="content_header_select">
      <a-select
        v-model:value="chosePro"
        class="m-2"
        placeholder="请选择数据展示的省份"
        size="small"
        @change="changePro"
        style="width: 160px"
      >
        <a-select-option
          v-for="item in allProList"
          :key="item.provId"
          :label="item.provName"
          :value="item.provId"
          :disabled="disAble(item)"
          >{{ item.provName }}</a-select-option
        >
      </a-select>
    </div>
    <div class="left" @click="goStorageCharging">{{ leftCon.title }}</div>

    <p>{{ title }}</p>
    <div class="right" @click="goSale">{{ rightCon.title }}</div>
    <!-- @click="goSale" -->
    <!-- @click="goSale" -->
    <!--  <div class="content_header_date">
        <div class="year">{{ year }}</div>
        <div class="month">{{ month }}</div>
      </div> -->
    <div class="content_header_btn" @click="goToStation">
      进入应用<DoubleRightOutlined />
    </div>
  </div>
</template>
<script setup>
const disAble = (e) => {
  /*  if (props.screenType === "storageAndSale") {
    return e.provId < 440000 && e.provId !== 0
  } */
  return false
}
const route = useRoute()
const router = useRouter()
const $api = inject("$api")
const props = defineProps({
  companyProvStatsList: {
    type: Array,
    default: () => [],
  },
  title: {
    type: String,
    default: "雷泽矩阵",
  },
  leftCon: {
    type: Object,
    default: () => {
      return {
        title: "雷泽充能脉络",
        path: "/DataScreen/StorageCharging",
      }
    },
  },
  rightCon: {
    type: Object,
    default: () => {
      return {
        title: "雷泽售能经纬",
        path: "/DataScreen/StorageAndSale",
      }
    },
  },
  screenType: {
    type: String,
    default: "storage",
  },
  defualPro: {
    type: Number || String,
    default: 0,
  },
})
const rightCon = ref({})
const leftCon = ref({})
watch(
  () => props.leftCon,
  (newValue) => {
    leftCon.value = newValue
  },
  {
    deep: true,
    immediate: true,
  }
)
watch(
  () => props.rightCon,
  (newValue) => {
    rightCon.value = newValue
  },
  {
    deep: true,
    immediate: true,
  }
)
/* ----------------------------------------------省份选择开始-------------------------------------- */

let allProList = ref([])
let companyProvStatsList = ref([])
let nationwide = {
  projectCount: companyProvStatsList.value.reduce(
    (acc, item) => acc + item.projectCount,
    0
  ),
  provId: 0,
  provName: "全国",
}
let chosePro = ref(null)
const initProList = () => {
  allProList.value = [...companyProvStatsList.value]
  allProList.value.push(nationwide)
}
const init = () => {
  if (props.screenType === "storageAndSale") {
    chosePro.value = 440000
  } else if (props.screenType === "storageCharging") {
    chosePro.value = "广东省"
  } else {
    chosePro.value = 0
  }
}
//选择省份改变
const emits = defineEmits(["changePro"])
const changePro = async (e) => {
  emits("changePro", e)
}
watch(
  () => props.companyProvStatsList,
  (newValue) => {
    companyProvStatsList.value = newValue

    initProList()
  }
)
watch(
  () => props.defualPro,
  (newValue) => {
    if (newValue || newValue === 0) {
      chosePro.value = newValue
      init()
    }
  },
  {
    immediate: true,
  }
)
onMounted(() => {})
/* ----------------------------------------------省份选择结束-------------------------------------- */
//进入电站
const goToStation = () => {
  router.replace("/FrontPage/StationOverview")
}
//储售大屏
const goSale = () => {
  router.replace(rightCon.value.path)
}
const goStorageCharging = () => {
  router.replace(leftCon.value.path)
}
</script>

<style scoped lang="less">
.content_header {
  width: 100%;
  height: 146px;
  background: url("@/assets/screen/headerBg1.png") no-repeat top / 100% 100%;
  position: relative;
  margin: 0 auto;
  &_logo {
    width: 99px;
    height: 33px;
    background: url("@/assets/screen/logo.png") no-repeat top / 100% auto;
    position: absolute;
    left: 40px;
    top: 10px;
  }
  &_date {
    position: absolute;
    right: 40px;
    top: 10px;
    color: #fff;
    text-align: right;
    .year {
      font-size: 22px;
    }
    .month {
      color: #50a2ff;
      font-size: 14px;
    }
  }
  &_select {
    position: absolute;
    left: 20px;
    top: 25px;
    ::v-deep(.ant-select-selector) {
      box-shadow: 0 0 0 1px #5a7181 inset !important;
    }
    :deep(.ant-select-selector) {
      background: transparent !important;
    }
  }
  p {
    font-size: 35px;
    text-align: center;
    line-height: 70px;
    font-weight: bolder;
    background-image: linear-gradient(to bottom, #ffffff, #a1c9f2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    margin-bottom: 0;
  }
  .left,
  .right {
    font-size: 18px;
    color: #fff;
    position: absolute;
    top: 13px;
    width: 10.78%;
    height: 48px;
    //background: rgba(0, 0, 0, 0.4);
    text-align: center;
    line-height: 48px;
    cursor: pointer;
  }
  .left {
    left: 18.5%;
    color: #d3e6f6;
    //cursor: pointer;
  }
  .right {
    right: 18.5%;
    color: #d3e6f6;
  }
  &_btn {
    font-size: 12px;
    background: rgba(145, 202, 255, 0.4);
    padding: 5px 10px;
    text-align: center;
    border: 1px solid #72b9fc;
    color: #fff;
    position: absolute;
    right: 40px;
    top: 25px;
    cursor: pointer;
  }
}
</style>
